//
//  ImageData.swift
//  FaceVerify
//
//  Created by duzexu on 2017/3/6.
//  Copyright © 2017年 duzexu. All rights reserved.
//

import Foundation
import RealmSwift

class ImageData: Object {
    
    dynamic var imagePath: String?
    dynamic var time: NSDate = NSDate()
    
    dynamic var faceId: String!
    dynamic var faceData: String?
    
// Specify properties to ignore (Realm won't persist these)
    
//  override static func ignoredProperties() -> [String] {
//    return []
//  }
}

extension ImageData {
    public static func updateData() -> Void {
        let realm = try! Realm()
        try! realm.write {
            let date = NSDate(timeIntervalSince1970: NSDate().timeIntervalSince1970-23*60*60)
            let toDelete = realm.objects(ImageData.self).filter("time <= %@", date)
            realm.delete(toDelete)
        }
    }
}
